#include <Arduino.h>

#ifndef IMU_H
#define IMU_H

  #define SC16IS752_CHANNEL_BOTH  0x00
  #define SC16IS750_REG_IOCONTROL 0X0E
  #define SC16IS752_CHANNEL_A     0x00
  #define SC16IS752_CHANNEL_B     0x01
  #define SC16IS750_REG_FCR       0x02
  #define SC16IS750_CRYSTCAL_FREQ 1843200UL
  #define SC16IS750_REG_MCR       0x04
  #define SC16IS750_REG_LCR       0x03
  #define SC16IS750_REG_DLL       0x00
  #define SC16IS750_REG_DLH       0x01
  #define SC16IS750_REG_RXLVL     0x09
  #define SC16IS750_REG_RHR       0x00
  #define SC16IS750_REG_LSR       0x05
  #define SC16IS750_REG_THR       0x00
  
  void INIT_IMU(void);
  int IMU_AVAILABLE(uint8_t channel);
  int IMU_READ(uint8_t channel);
  void IMU_TX(uint8_t channel, uint8_t val);
  
  void ResetDevice(void);
  void FIFOEnable(uint8_t channel, uint8_t fifo_enable);
  uint8_t ReadRegister(uint8_t channel, uint8_t reg_addr);
  void WriteRegister(uint8_t channel, uint8_t reg_addr, uint8_t val);
  void SetBaudrate(uint8_t channel, uint32_t baudrate);
  void SetLine(uint8_t channel, uint8_t data_length, uint8_t parity_select, uint8_t stop_length);
  uint8_t FIFOAvailableData(uint8_t channel);
  int ReadByte(uint8_t channel);

#endif
